package com.htfyun.ft.fragment.factory;

import android.content.Context;
import android.graphics.Color;

import com.htfyun.ft.FTApplication;
import com.htfyun.ft.R;

public enum ResultAttr {
    MA("MA", Color.BLUE, R.string.test_result_unknown),
    PASS("Pass", Color.GREEN, R.string.test_result_pass),
    FAIL("Fail", Color.RED, R.string.test_result_fail),
    ;
    private final String result;
    private final int showColor;
    private final int resultRes;

    private ResultAttr(String result, int showColor, int resultRes) {
        this.result = result;
        this.showColor = showColor;
        this.resultRes = resultRes;
    }

    public String getResultName() {
        final Context context = FTApplication.getContext();

        return context.getString(resultRes);
    }

    public String getResult() {
        return result;
    }

    public int getShowColor() {
        return showColor;
    }

    public static ResultAttr toResultAttr(String result) {
        for (ResultAttr attr : ResultAttr.values()) {
            if (attr.getResult().equalsIgnoreCase(result)
                || attr.getResultName().equalsIgnoreCase(result)) {
                return attr;
            }
        }
        return MA;
    }
}
